﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using AMatysiak.Methods;
using System;

namespace AMatysiakTest.Methods
{
    [TestClass]
    public class FormatWithTest
    {
        [TestMethod]
        public void emptyPattern()
        {
            string pattern = "";
            string result = pattern.FormatWith();

            Assert.AreEqual("", result);
        }

        [TestMethod]
        public void patternWithOneArg()
        {
            string pattern = "Hi, {0}!";
            string result = pattern.FormatWith("Adam");

            Assert.AreEqual("Hi, Adam!", result);
        }

        [TestMethod]
        public void patternWithTwoArg()
        {
            string pattern = "Pair [ Key = {0}, Value = {1} ]";
            string result = pattern.FormatWith("klucz", "wartość");

            Assert.AreEqual("Pair [ Key = klucz, Value = wartość ]", result);
        }

        [TestMethod]
        [ExpectedException(typeof(FormatException))]
        public void patternWithOneArgInsteadOfTwo()
        {
            string pattern = "Pair [ Key = {0}, Value = {1} ]";
            string text = pattern.FormatWith("klucz");
        }

        [TestMethod]
        public void patternWithTwoArgInsteadOfOne()
        {
            string pattern = "Hi, {0}!";
            string result = pattern.FormatWith("Adam", "Matysiak");

            Assert.AreEqual("Hi, Adam!", result);
        }
    }
}
